<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Schema;

class CreateUserAddrsTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('user_addrs', function (Blueprint $table) {
            $table->bigIncrements('id');
            $table->integer('user_id')->comment('=users.id');
            $table->string('username')->comment('收货人姓名');
            $table->string('phone')->comment('收货人手机号');
            $table->string('areaCode')->default('')->comment('地址编号');
            $table->string('province')->default('')->comment('省份');
            $table->string('city')->default('')->comment('城市');
            $table->string('street')->default('')->comment('区/街道');
            $table->string('detail')->default('')->comment('详细地址');
            $table->tinyInteger('is_default')->default(0)->comment('是否默认1是0否');
            $table->tinyInteger('is_deleted')->default(0)->comment('是否删除1是0否');
            $table->dateTime('last_used_at')->nullable();
            $table->timestamps();
        });

        DB::statement("ALTER TABLE `user_addrs` comment '用户地址表';");

    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('user_addrs');
    }
}
